package com.graduation.adminservice.controller;

import com.graduation.common.domain.dto.PageDTO;
import com.graduation.pojo.po.Tag;
import com.graduation.pojo.query.TagQuery;
import com.graduation.pojo.vo.TagVO;
import com.graduation.service.TagService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/tag")
@RequiredArgsConstructor
public class TagController {

    private final TagService tagService;

    @GetMapping("/page")
    public PageDTO<TagVO> pageTags(TagQuery query) {
        return tagService.pageTags(query);
    }

    @GetMapping("/list")
    public List<Tag> list() {
        return tagService.list();
    }

    @GetMapping("/{id}")
    public TagVO getTagById(@PathVariable(name = "id") Long id) {
        return tagService.getTagById(id);
    }

    @PostMapping
    public void saveTag(@RequestBody Tag tag) {
        tagService.saveTag(tag);
    }

    @PutMapping
    public void updateTag(@RequestBody Tag tag) {
        tagService.updateTag(tag);
    }

    @DeleteMapping("/{id}")
    public void deleteTag(@PathVariable(name = "id") Long id) {
        tagService.deleteTag(id);
    }

}
